package com.yunyan.util.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.CellExtra;
import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.read.metadata.holder.ReadRowHolder;
import com.yunyan.entity.RankData;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;

public class RankListener extends AnalysisEventListener<RankData> {


    private List<RankData> dataList = new ArrayList<>();

    private volatile boolean finished = false;
    @Override
    public void invoke(RankData rankData, AnalysisContext context) {
        ReadRowHolder readRowHolder = context.readRowHolder();
        int rowIndex = readRowHolder.getRowIndex();
        if(rowIndex < 4) {
            // 忽略
            return;
        }
        System.out.println(rankData);
        dataList.add(rankData);

    }

    public List<RankData> getDataList() {
        while (!finished) {

        }
        return dataList;
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        finished = true;
    }
}